@(account: gitbucket.core.model.Account, info: Option[Any])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.util.LDAPUtil
@import context._
@import gitbucket.core.view.helpers._
@html.main("Edit your profile"){
<div class="container">
  <div class="row-fluid">
    <div class="span3">
      @menu("profile", settings.ssh)
    </div>
    <div class="span9">
      @helper.html.information(info)
      @if(LDAPUtil.isDummyMailAddress(account)){<div class="alert alert-danger">Please register your mail address.</div>}
      <form action="@url(account.userName)/_edit" method="POST" validate="true">
      <div class="box">
        <div class="box-header">Profile</div>
        <div class="box-content">
          <div class="row-fluid">
            <div class="span6">
              @if(account.password.nonEmpty){
                <fieldset>
                  <label for="password" class="strong">
                    Password (input to change password):
                  </label>
                  <input type="password" name="password" id="password" value="" autocomplete="off"/>
                  <span id="error-password" class="error"></span>
                </fieldset>
              }
              <fieldset>
                <label for="fullName" class="strong">Full Name:</label>
                <input type="text" name="fullName" id="fullName" value="@account.fullName"/>
                <span id="error-fullName" class="error"></span>
              </fieldset>
              <fieldset>
                <label for="mailAddress" class="strong">Mail Address:</label>
                <input type="text" name="mailAddress" id="mailAddress" value="@if(!LDAPUtil.isDummyMailAddress(account)){@account.mailAddress}"/>
                <span id="error-mailAddress" class="error"></span>
              </fieldset>
              <fieldset>
                <label for="url" class="strong">URL (optional):</label>
                <input type="text" name="url" id="url" style="width: 300px;" value="@account.url"/>
                <span id="error-url" class="error"></span>
              </fieldset>
            </div>
            <div class="span6">
              <fieldset>
                <label for="avatar" class="strong">Image (optional):</label>
                @helper.html.uploadavatar(Some(account))
              </fieldset>
            </div>
          </div>
          <div style="margin-top: 20px;">
            <div class="pull-right">
              <a href="@path/@account.userName/_delete" class="btn btn-danger" id="delete">Delete account</a>
            </div>
            <input type="submit" class="btn btn-success" value="Save"/>
            @if(!LDAPUtil.isDummyMailAddress(account)){<a href="@url(account.userName)" class="btn">Cancel</a>}
          </div>
        </div>
      </div>
    </form>
  </div>
</div>
}
<script>
$(function(){
  $('#delete').click(function(){
    return confirm('Once you delete your account, there is no going back.\nAre you sure?');
  });
});
</script>
